agents.anac.y2011.TheNegotiator
Class Queue

java.lang.Object
  extended by agents.anac.y2011.TheNegotiator.Queue

public class Queue
extends java.lang.Object

Array-based implementation of the queue.

Author:
Mark Allen Weiss

Constructor Summary
Queue()
          Construct the queue.
 
Method Summary
 java.lang.Double dequeue()
          Return and remove the least recently inserted item from the queue.
 void enqueue(java.lang.Double x)
          Insert a new item into the queue.
 java.lang.Double getFront()
          Get the least recently inserted item in the queue.
 boolean isEmpty()
          Test if the queue is logically empty.
 void makeEmpty()
          Make the queue logically empty.
 int size()
           
 java.lang.Double[] toArray()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue()
Construct the queue.

Method Detail

isEmpty

public boolean isEmpty()
Test if the queue is logically empty.

Returns:
true if empty, false otherwise.

makeEmpty

public void makeEmpty()
Make the queue logically empty.


dequeue

public java.lang.Double dequeue()
Return and remove the least recently inserted item from the queue.

Returns:
the least recently inserted item in the queue.
Throws:
UnderflowException - if the queue is empty.

getFront

public java.lang.Double getFront()
Get the least recently inserted item in the queue. Does not alter the queue.

Returns:
the least recently inserted item in the queue.
Throws:
UnderflowException - if the queue is empty.

enqueue

public void enqueue(java.lang.Double x)
Insert a new item into the queue.

Parameters:
x - the item to insert.

size

public int size()

toArray

public java.lang.Double[] toArray()
Returns:
array of queue (watch out, contains empty cells)